/*
 * @Author: 你的名字
 * @Date: 2022-09-21 15:00:51
 * @FilePath: /demo-gather/src/main.js
 * @Description: 
 */
import Vue from 'vue'
import App from './App.vue'
import axios from 'axios' 
import router from './router';
import './plugins/rem'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// import VueRouter from 'vue-router';
// import Vue from 'vue';
// Vue.use(VueRouter);
Vue.directive('resize', {
	inserted: function (el) {
		let resizeable = false,
			minW = '400', minH = '225',
			val, clientY
		el.addEventListener('mousedown', resizeMove)
		document.addEventListener('mousemove', resizeDomMove)
		document.addEventListener('mouseup', resizeDomUp)
		function getAddress(ev) {
			let xPos1, yPos1, offset, cls;
			cls = '';

			// xPos2 = ev.offsetX;
			// yPos2 = ev.offsetY;


			yPos1 = ev.clientY;
			xPos1 = ev.clientX;

			offset = 10;
			// if (yPos2 < offset) cls += 'n';
			if (yPos1 > el.offsetHeight + el.getBoundingClientRect().top - offset) cls += 's';
			// if (xPos2 < offset) cls += 'w';
			if (xPos1 > el.offsetWidth + el.getBoundingClientRect().left - offset) cls += 'e';

			return cls;
		}
		function resizeMove(e) {
			e.stopPropagation()
			let d = getAddress(e)
			if (d !== '') {
				resizeable = true
				val = d
				// clientX = e.clientX
				clientY = e.clientY
			}
		}
		function resizeDomMove(e) {
			let d = getAddress(e)
			let cursor
			if (d === '') cursor = 'default';
			else if (d === 'se') { cursor = d + '-resize' }
			el.style.cursor = cursor;
			if (resizeable) {
				if (val == 'se') {
					// 等比例缩放
					el.style.width = Math.max(minW, el.offsetWidth + (e.clientY - clientY)) + 'px'
					el.style.height = Math.max(minH, el.offsetHeight + ((e.clientY - clientY) * 0.5625)) + 'px'
					// clientX = e.clientX
					clientY = e.clientY
				}
			}
		}
		function resizeDomUp() {
			resizeable = false
		}
	}
})
Vue.prototype.$EventBus = new Vue()

Vue.config.productionTip = false;
Vue.prototype.$axios = axios;
Vue.use(ElementUI);
new Vue({
  render: h => h(App),
  router:router
}).$mount('#app')
